package importsejb;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.ejb.Stateless;
import javax.management.Query;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery; 

import imports.Contacto;


@Stateless
public class ContactoEJB {

@PersistenceContext(unitName = "Sig_WorkFlow_And_Persistence")
private static EntityManager em;

public static ArrayList<Contacto> findContactos() {
	TypedQuery<Contacto> query = em.createNamedQuery("Contacto.findAll", Contacto.class);
	return (ArrayList<Contacto>)query.getResultList();
}
	
	public Contacto con = new Contacto();
	
	
	
	//public static ArrayList<Contacto> findContactos() {
		//TypedQuery<Contacto> query = em.createNamedQuery("findAll", Contacto.class);
		//return (ArrayList<Contacto>)query.getResultList();
	//}
	
	public void save(Contacto contacto) {  
        em.persist(contacto);  
    }  
	
	public void update(Contacto contacto) {
		 em.merge(contacto);
	
	}
	public void remove(Contacto contacto){
		em.remove(contacto);
	}

	public static Contacto createContacto(Contacto con2) {
		// TODO Auto-generated method stub
		return null;
	}

	
	public List findAll() {
		Query query = (Query) em.createNamedQuery("Contacto.findAll");  
        return ((javax.persistence.Query) query).getResultList();  
    }  
	}

